unit ufrmCustomFrame;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
  System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Layouts;

type
  TfrmCustomFrame = class(TForm)
    MainLayout: TLayout;
  protected
    FForm: TForm;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

    procedure ApplyParent(AForm: TForm; AParent: TControl; AVisible: boolean = false); virtual;
    function PrepareView(): boolean; virtual;

    property OwnerForm: TForm read FForm;
  end;

var
  frmCustomFrame: TfrmCustomFrame;

implementation

{$R *.fmx}

{ TfrmCustomFrame }

procedure TfrmCustomFrame.ApplyParent(AForm: TForm; AParent: TControl; AVisible: boolean);
begin
  FForm:= AForm;
  MainLayout.Parent:= AParent;
  MainLayout.Visible:= AVisible;
end;

constructor TfrmCustomFrame.Create(AOwner: TComponent);
begin
  inherited;
  FForm:= nil;
end;

destructor TfrmCustomFrame.Destroy;
begin
  if MainLayout.Parent <> self then
    FParent:= self;
  inherited;
end;

function TfrmCustomFrame.PrepareView: boolean;
begin
  result:= True;
end;

end.
